package com.ecnu.codelearn.thread;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @Author: 曹培胜
 * @Date: 2021/09/13/14:36
 * @Description:
 */
public class CreateThreadRunnable implements Runnable {
    private Boolean flag = true;


    @Override
    public void run() {
        while (flag) {
            System.out.println("thread...run");
        }
    }

    public void stop() {
        this.flag = false;
    }

    public static void main(String[] args) {
        CreateThreadRunnable p = new CreateThreadRunnable();
        new Thread(p).start();



        for (int i = 0; i < 100; i++) {
            System.out.println("i=" + i);
            if (i == 99) {
                p.stop();
            }
        }
    }
}
